package com.atguigu.ossservice.controller;

import com.atguigu.commonutils.R;
import com.atguigu.ossservice.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api(description="阿里云文件管理")
@RestController
@RequestMapping("/ossservice/fileoss")
public class FileController {

    @Resource
    private FileService fileService;

    @ApiOperation(value = "文件上传")
    @PostMapping("uploadFile")
    public R upload(
            @ApiParam(name = "file", value = "文件", required = true)
            MultipartFile file) {

        String url = fileService.uploadFileOSS(file);
        //返回r对象
        return R.ok().message("文件上传成功").data("url", url);

    }
}